import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:sui_shou_pai/module/effect.dart';

import 'color.dart';
import 'data.dart';

Widget initAppBar(String title, List<Tab> tabs, TabController tabController) {
  return PreferredSize(
      child: AppBar(
        elevation: 0,
        flexibleSpace: initFlexibleSpace(title),
        bottom: initTabBar(tabs, tabController),
      ),
      preferredSize: Size.fromHeight(topBarHeight));
}

Widget initFlexibleSpace(String title) {
  return Container(
    decoration:
        BoxDecoration(color: Colors.white, boxShadow: [shadowOffsetY2()]),
    padding: EdgeInsets.fromLTRB(16, statusBarHeight + 12, 16, 0),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[initTitleBar(title), initSearchBar()],
    ),
  );
}

Widget initTitleBar(String title) {
  return Text(
    title,
    style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
  );
}

Widget initSearchBar() {
  return Container(
    height: 40,
    margin: EdgeInsets.only(top: 16, bottom: 16),
    decoration:
        BoxDecoration(color: greyF3F3F3, borderRadius: borderRadiusAll8()),
    child: TextField(
      style: TextStyle(
        fontSize: 16,
        color: Colors.grey,
      ),
      decoration: InputDecoration(
        hintText: "搜索",
        border: InputBorder.none,
        prefixIcon: Icon(
          Icons.search,
          color: Colors.grey,
        ),
      ),
    ),
  );
}

Widget initTabBar(List<Tab> tabs, TabController tabController) {
  return TabBar(
    controller: tabController,
    tabs: tabs,
  );
}
